<template>
  <van-field v-model="modelValue" :class="item.class" :border="true" :maxlength="item.colWidth" :disabled="item.disabled" readonly>
    <template #label>
      <span class="custom-title">{{ label }}
        <van-icon v-if="help" name="question" @click="showHelp" />
      </span>
    </template>
  </van-field>
</template>

<script>
import EleBase from './EleBase'

export default {
  name: 'EleLabel',
  extends: EleBase,
  props: {
    item: {
      type: Object, // 类型
      default: null // 默认值
    }
  },
  data() {
    return {
      modelValue: this.item.text
    }
  },
  computed: {
    errMsg() {
      let str = ''
      if (this.item.required) {
        if (this.item.undermsg === '') {
          str = '请选择' + this.item.label
        } else {
          str = this.item.undermsg
        }
      }
      return str
    },
    placeholder() {
      let str = ''
      console.log('modelValue=' + this.modelValue)
      if (this.modelValue === '') {
        if (this.item.placeholder) {
          str = this.item.placeholder
        } else if (this.item.label) {
          str = '请输入' + this.item.label
        }
      }
      return str
    }
  },
  mounted () {
    // console.log('label item:' + this.item.value)
    // console.log(this.item)
  },
  methods: {
  }
}
</script>
